@(comments: gitbucket.core.model.CommitComments,
  hasWritePermission: Boolean,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  latestCommitId: Option[String] = None)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
<div class="panel panel-default">
  <div class="panel-heading">
    <span class="monospace">@comments.fileName</span>
    @if(!latestCommitId.contains(comments.comments.head.commitId)) {
      <span class="pull-right"><a href="javascript:void(0);" onclick="$('.fold-comments-@comments.comments.head.commentId').toggle();"><i class="octicon octicon-unfold"></i></a></span>
    }
  </div>
  <div style="@if(!latestCommitId.contains(comments.comments.head.commitId)){display: none;}" class="fold-comments-@comments.comments.head.commentId">
    @comments.diff.map(helpers.diff)
    <div class="panel-body">
    @comments.comments.map { comment =>
      @gitbucket.core.helper.html.commitcomment(comment, hasWritePermission, repository, latestCommitId)
    }
    </div>
  </div>
</div>

@if(!latestCommitId.contains(comments.comments.head.commitId)) {
  <script>
    $(function(){
      var foldComments = $('.fold-comments-@comments.comments.head.commentId');
      if(foldComments.find('input:checkbox:not(:checked)').length > 0){
        foldComments.show();
      }
    });
  </script>
}
